<#assign n=tableClass.shortClassName?length-3 />
<#assign noDTO=tableClass.shortClassName?substring(0,n) />
package ${baseInfo.packageName};

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${tableClass.fullClassName};
import ${serviceInterface.packageName}.${serviceInterface.fileName};
import ${mapperInterface.packageName}.${mapperInterface.fileName};
import ${serviceInterface.packageName}.base.support.PageData;
import ${insertVo.packageName}.${noDTO}InsertVo;
import ${queryVo.packageName}.${noDTO}QueryVo;
import ${updateVo.packageName}.${noDTO}UpdateVo;
<#if baseService??&&baseService!="">
import ${baseService};
    <#list baseService?split(".") as simpleName>
        <#if !simpleName_has_next>
            <#assign serviceSimpleName>${simpleName}</#assign>
        </#if>
    </#list>
</#if>
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
* ${tableClass.remark}模块-service实现
*
* @author qi
* @date ${.now?string("yyyy-MM-dd HH:mm:ss")}
*/
@Service
public class ${baseInfo.fileName} extends ServiceImpl<${mapperInterface.fileName}, ${tableClass.shortClassName}>
    implements ${serviceInterface.fileName}{

    @Override
    public PageData<${tableClass.shortClassName}> listPaging(Object obj) {
        ${noDTO}QueryVo param = (${noDTO}QueryVo) obj;
        LambdaQueryWrapper<${tableClass.shortClassName}> wrapper = new LambdaQueryWrapper<>();

        //动态查询条件
        // if (!ObjectUtils.isEmpty(param.getXXX())) {
        //     wrapper.eq(${tableClass.shortClassName}::getDeleted, param.getXXX());
        // }

        //动态查询条件 or嵌套  and (a=1 or b=2)
        // if (!ObjectUtils.isEmpty(param.getXXX())) {
        //     wrapper.and(
        //             queryWrapper -> queryWrapper.eq(${tableClass.shortClassName}::getDeleted, param.getXXX())
        //                     .or().like(${tableClass.shortClassName}::getDeleted, param.getXXX())
        //     );
        // }

        //默认排序方式为 created_time desc 前段未传 order 参数时生效
        Page page = page(param.pageInstance(), wrapper);

        //更改默认排序方式 前段未传 order 参数时生效
        // Page page = page(param.pageInstance(OrderItem.desc("modified_time")), wrapper);

        return new PageData<>(page);
    }

    @Override
    public ${tableClass.shortClassName} insert(Object obj) {
        ${noDTO}InsertVo param = (${noDTO}InsertVo) obj;
        ${tableClass.shortClassName} dto = new ${tableClass.shortClassName}();
        BeanUtils.copyProperties(param, dto);
        // dto.setXXX("");
        save(dto);
        return dto;
    }

    @Override
    public ${tableClass.shortClassName} update(Object obj) {
        ${noDTO}UpdateVo param = (${noDTO}UpdateVo) obj;
        ${tableClass.shortClassName} dto = new ${tableClass.shortClassName}();
        BeanUtils.copyProperties(param, dto);
        // dto.setXXX("");
        updateById(dto);
        return getById(dto.getId());
    }
}




